<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  String context = request.getContextPath();
%>
<html>
<head>
  <title>宿舍管理系统</title>
  <style>
    body, html {
      margin: 0;
      padding: 0;
      font-family: Arial, sans-serif;
    }
    .header {
      background-color: #007BFF;
      color: white;
      padding: 10px;
      text-align: center;
    }
    .sidebar {
      width: 200px;
      background-color: #f8f9fa;
      float: left;
      height: 100vh;
      padding-top: 20px;
    }
    .sidebar a {
      display: block;
      padding: 10px;
      text-decoration: none;
      color: black;
    }
    .sidebar a:hover {
      background-color: #ddd;
    }
    .content {
      margin-left: 210px;
      padding: 20px;
    }
    .table-container {
      background-color: #fff;
      padding: 20px;
      border-radius: 5px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
    table {
      width: 100%;
      border-collapse: collapse;
    }
    th, td {
      border: 1px solid #ddd;
      padding: 8px;
      text-align: center;
    }
    th {
      background-color: #f2f2f2;
    }
    .btn {
      background-color: #4CAF50;
      color: white;
      padding: 5px 10px;
      border: none;
      border-radius: 5px;
      cursor: pointer;
    }
    .btn:hover {
      background-color: #45a049;
    }
  </style>
</head>
<body>
<jsp:include page="/nav.jsp"/>
<div class="content">
  <div class="table-container">
    <h2>缺勤记录</h2>
    <button class="btn" onclick="goToAddPage()">添加</button >
    <table>
      <tr>
        <th>日期</th>
        <th>学号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>宿舍楼</th>
        <th>寝室</th>
        <th>备注</th>
        <th>操作</th>
      </tr>
      <c:forEach var="i" items="${requestScope.list}">
      <tr>
        <td>${i.lessdate}</td>
        <td>${i.user_id}</td>
        <td>${i.name}</td>
        <td>${i.gender}</td>
        <td>${i.building_card}</td>
        <td>${i.room_num}</td>
        <td>无</td>
        <td>
          <button class="btn" onclick="goToUpdatePage(${i.user_id})"  value="${i.user_id}" >修改</button>
          <button class="btn" onclick="goToDeletePage(${i.user_id})" value="${i.user_id}">删除</button>
        </td>
      </tr>
      </c:forEach>
    </table>
  </div>
</div>
<script>
  function goToAddPage() {
    window.location.href = 'absenceAdd';
  }
  function goToUpdatePage(id) {
    window.location.href = 'updateAbsence?id='+id;
  }
  function goToDeletePage(id) {
    window.location.href = 'deleteabsence?id=' + id;;
  }
</script>
</body>
</html>